<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<script type="text/javascript">
	var artClassGrid=null;
	$(function(){
		artClassGrid = $("#art_class_grid").ligerGrid({
				title : '所有分类列表',
                columns: [
							{
								display: ' 操作 ', 
								name: 'identifier',
								width:100,
								isAllowHide: false, 
								isSort : false,
								render: function (record, rowindex, value, column){
									var html = '<a onclick="showUpdate(\''+ value + '\',\''+ record.name + '\')" href="javascript:;">修改</a>&nbsp;<a onclick="deleteClass(\''+ value + '\')" href="javascript:;">作废</a>&nbsp;'; 
									return html; 
								}
							},
                     	 { display: '当前状态', name: 'enabled',isSort : false,
       	                  render: function(record, rowindex, value, column){
       	                	  if(value){
       	                		  return "<span>可用</span>"; 
       	                	  }else{
       	                		  return "<span>作废</span>"; 
       	                	  }
       	                	 
       	                  }},
	                  { display: '分类名', name: 'name',isSort : false },
	                  { display: '父类名称', name: 'parentName',isSort : false}
                ], 
                pageSize:30,
                root :'list',
                record:'totalRecord',
                url: "/misc/artFind/allClassGrid.htm", 
                width: '80%',height:'80%'
            });


	});
	
	function search(){
		artClassGrid.options.parms = [{name:'name',value:$("#search_name").val()}];
		artClassGrid.loadData();
	}
	function showUpdate(id,name){
		$("#updateId").val(id);
		$("#updateName").val(name);
		$("#updateClass").show();
	}
	function updateClass(id){
		var name = $.trim($("#updateName").val());
		if(name==""){
			alert("请填写频道名称！");
			return;
		}
		$.post("/misc/cms/editchannel.htm",{
			identifier:$("#updateId").val(),
			name : $("#updateName").val()
		},function(data){
			if (data == "success") {
				alert("更新,请刷新页面！");
			}else{
				$.ligerDialog.warn("系统有点抽经，请稍候重试！");
			}
		});
	}
	function deleteClass(id){
		$.post("/misc/artPic/deleteClassList.htm", {
			identifier : id
		}, function(data) {
			if (data == 'success') {
				alert("作废成功！");
				artClassGrid.loadData();
			}
		});
	}
</script>
<table>
	<tr>
		<td>
			<div id="searchbar">
			   类型名称：<input id="search_name" type="text" />
			    	  <input id="btnOK" type="button" value="查询" onclick="search()" />
			</div>
		</td>
	</tr>
</table>
<div id="art_class_grid" style="margin:0; padding:0 ;" ></div>

<div style="text-align: center; display: none;" id="updateClass" >
			<table width="40%">
				<tr>
					<td colspan="2" align="center">
							<input type="text" id="updateName" style="border:1px solid #a3c0e8; padding:3px 5px;width: 350px;">
							<input type="hidden"  id="updateId"/>
					</td>
				</tr>
				<tr>
					<td colspan="2" align="center">
						<button type="button" style="padding:2px 20px;"   onclick="updateClass()">修改</button>
					</td>
				</tr>	
			</table>
		</div>
